package com.fancy.learncenter.ui.view.date.custom;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.fancy.learncenter.R;
import com.fancy.learncenter.ui.view.date.adapters.AbstractWheelTextAdapter;


/**
 * Created by linhuasen on 15/12/25.
 */
public class DayArrayAdapter extends AbstractWheelTextAdapter {

    private int today;
    private int beginDay;
    private int endDay;

    protected DayArrayAdapter(Context context,int beginDay,int endDay) {
        super(context, R.layout.layout_time, NO_RESOURCE);
        setItemTextResource(R.id.time);
        this.beginDay = beginDay;
        this.endDay = endDay;
    }


    public int getToday(){
        return today;
    }

    @Override
    public View getItem(int index, View cachedView, ViewGroup parent) {
        View view = super.getItem(index, cachedView, parent);
        TextView time = (TextView) view.findViewById(R.id.time);
        today = index + 1;
        time.setText(today + "日");
        return view;
    }

    @Override
    public int getItemsCount() {
        return this.endDay-this.beginDay + 1;
    }

    @Override
    protected CharSequence getItemText(int index) {
        return getToday() + "日";
    }
}
